local mod = BigWigs:NewBoss("LK Valkyr Marker", "Icecrown Citadel")
if not mod then return end
mod:RegisterEnableMob(36597)

local counter = 1
local valkyrs = {}

function mod:OnBossEnable()
    L = BigWigs.bossCore:GetModule("The Lich King"):GetLocale()

    self:Yell("Engage", L["engage_trigger"])
    self:Log("SPELL_SUMMON", "Valkyr", 69037)
    self:Death("Disable", 36597)
end

function mod:OnEngage()
    counter = 1
    wipe(valkyrs)
end

do
    local f = CreateFrame("Frame")
    local total = 0
    f:SetScript("OnUpdate", function(self, elapsed)
        total = total + elapsed
        if total > 0.2 then
            for uid in pairs(valkyrs) do
                local mobId = mod:GetUnitIdByGUID(uid)
                if mobId then
                    valkyrs[uid] = nil
                    SetRaidTarget(mobId, counter)
                    counter = counter + 1
                end
            end
            if counter > 3 then counter = 1 end
            if not next(valkyrs) then
                self:Hide()
            end
            total = 0
        end
    end)
    f:Hide()

    function mod:Valkyr(_, _, _, _, _, _, _, _, _, dGUID)
        valkyrs[dGUID] = true
        f:Show()
    end
end
